<?php

class System_Model_Standart
{
    protected $_row;
    protected $_dbTable;
    
    public function __construct($class, $id = null) {
        
        $class = explode('_', get_class($this));
        $class = 'System_Model_DbTable_' . $class[count($class) - 1] . '()';
        $this->_dbTable = new $class;
        if ($id) {
            $this->_row = $this->_dbTable->find($id)->current(); 
        } else {
            $this->_row = $this->_dbTable->createRow();
        }
    }
    
    public function __set($name, $value) {
        if(isset($this->_row->$name)){
            $this->_row->$name = $value;
        }
    }
    
    public function __get($name) {
        if(isset($this->_row->$name)){
            return $this->_row->$name;
        }
    }
}

